package com.qfedu.controller;

import com.qfedu.common.JsonResult;
import com.qfedu.pojo.Report;
import com.qfedu.service.ReportService;
import com.qfedu.utils.StrUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author guo
 */
@Controller
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;
    @RequestMapping("/salary.do")
    @ResponseBody
    public Map<String, Object> findAll(Integer id){
        List<Report> list = reportService.select(id);

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", 2);
        map.put("data", list);
        return map;
    }
    @RequestMapping("/update.do")
    @ResponseBody
    public JsonResult update(HttpSession session){
        Report report = new Report();
        Report report1 = (Report)session.getAttribute(StrUtils.LOGIN_USER);

        report.setId(report1.getId());
        report.setName(report1.getName());
        report.setSalary(report1.getSalary());
        reportService.update(report);
        return new JsonResult(1,"修改成功");
    }
}
